package com.commonly.commonlyUsed.线程;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/thread")
public class demoThread {

    @RequestMapping("/demo")
    public String demo(HttpServletRequest request, HttpServletResponse response) throws InterruptedException {
        String sleep = request.getParameter("sleep");
        if(sleep.equals("on")){
            //休眠10s
            Thread.sleep(10000);
            return "sleep on";
        }else {
            return sleep;
        }

    }
}
